package model;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "fee")
public class Fee {
	public static final String USER_ID_FIELD_NAME = "user_id";
	public static final String CATEGORY_ID_FIELD_NAME = "cate_id";
	@DatabaseField(generatedId = true)
	private int id;
	@DatabaseField(canBeNull = true, foreign = true, columnName = USER_ID_FIELD_NAME, foreignAutoRefresh = true)
	private User user;
	@DatabaseField(canBeNull = false)
	private String name;
	@DatabaseField(canBeNull = false, foreign = true, columnName = CATEGORY_ID_FIELD_NAME, foreignAutoRefresh = true)
	private Category cate;
	@DatabaseField(canBeNull = false)
	private int money;
	@DatabaseField(canBeNull = false)
	private String time;
	@DatabaseField
	private String comment;
	public Fee(User user, String name, Category cate, int money, String time, String comment) {
		this.user = user;
		this.name = name;
		this.cate = cate;
		this.money = money;
		this.time = time;
		this.comment = comment;
	}
	
	public Fee() {
		
	}
	
	public int getId() {
		return id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Category getCate() {
		return cate;
	}

	public void setCate(Category cate) {
		this.cate = cate;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cate == null) ? 0 : cate.hashCode());
		result = prime * result + ((comment == null) ? 0 : comment.hashCode());
		result = prime * result + id;
		result = prime * result + money;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Fee other = (Fee) obj;
		if (cate == null) {
			if (other.cate != null)
				return false;
		} else if (!cate.equals(other.cate))
			return false;
		if (comment == null) {
			if (other.comment != null)
				return false;
		} else if (!comment.equals(other.comment))
			return false;
		if (id != other.id)
			return false;
		if (money != other.money)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Fee [id=" + id + ", user=" + user + ", name=" + name + ", cate=" + cate + ", money=" + money + ", time="
				+ time + ", comment=" + comment + "]";
	}

	
	
	
}
